PROJECT( QWHATTODO ) 
cmake_minimum_required (VERSION 2.6)
find_package(Qt4 REQUIRED )
find_package(Boost REQUIRED )

SET( APP_VERSION_MAJOR "0" )
SET( APP_VERSION_MINOR "1" )
SET( APP_VERSION_PATCH "0" )

if(WIN32)
ADD_DEFINITIONS( -Wall )
else(WIN32)
ADD_DEFINITIONS( -Wall -O2 )
SET(CMAKE_BUILD_TYPE Debug)
endif(WIN32)

#IF( WIN32 )
#    SET(CMAKE_CREATE_WIN32_EXE -subsystem:windows)
#ENDIF( WIN32 )

SET( QT_USE_QTNETWORK 1 )
SET(TIXML_USE_STL 1)

SET( SRCS 
    src/main.cpp
    src/mainwindowimpl.cpp
    src/ftphandler.cpp
    src/configdlg.cpp
    src/actioncollection.cpp
    src/settings.cpp
    src/shortcuts.cpp
    src/qlogger.cpp    
    src/task.cpp
    src/taskcontainer.cpp
    src/customprogresswidget.cpp
    src/tinyxml/tinystr.cpp
    src/tinyxml/tinyxml.cpp
    src/tinyxml/tinyxmlerror.cpp
    src/tinyxml/tinyxmlparser.cpp
     ) 
SET( HDRS 
    src/mainwindowimpl.h
    src/globals.h
    src/ftphandler.h
    src/configdlg.h
    src/common.h
    src/actioncollection.h    
    src/settings.h
    src/shortcuts.h
    src/qlogger.h    
    src/task.h
    src/taskcontainer.h
    src/customprogresswidget.h
    src/tinyxml/tinystr.h
    src/tinyxml/tinyxml.h
    )
	
SET( UI_FORMS ui/configdlg.ui)
SET( APP_RSC resources/main_resources.qrc )
SET(CMAKE_VERBOSE_MAKEFILE OFF)
#SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
#SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

QT4_ADD_RESOURCES(APP_RSC_SCRS ${APP_RSC})
QT4_WRAP_CPP(QT_MOC_SRC src/mainwindowimpl.h  src/ftphandler.h src/configdlg.h src/customprogresswidget.h)
QT4_WRAP_UI (UI_HDRS ${UI_FORMS} )
INCLUDE(${QT_USE_FILE})
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${Boost_INCLUDE_DIRS})

IF(WIN32)
IF(CMAKE_C_FLAGS_RELEASE )
SET(SUBSYSTEM WIN32)
ADD_DEFINITIONS(-D_AFXDLL)
SET(CMAKE_MFC_FLAG 2)
ELSEIF(CMAKE_C_FLAGS_DEBUG)
SET(WIN32_EXECUTABLE OFF )
ENDIF()
ENDIF(WIN32)

ADD_EXECUTABLE( QWhatToDo ${SUBSYSTEM} ${QT_MOC_SRC} ${SRCS} ${APP_RSC_SCRS} ${HDRS} ${UI_HDRS})
TARGET_LINK_LIBRARIES( QWhatToDo ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES} ${LIB} )

if( WIN32 )
Find_File(qtgui QtGui4.dll PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
Find_File(qtcore QtCore4.dll PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
Find_File(qtmain qtmain.lib PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
Find_File(qtnetwork qtnetwork4.dll PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
INSTALL(FILES ${qtgui} ${qtcore} ${qtmain} ${qtnetwork} DESTINATION bin )
ENDIF( WIN32 )

INSTALL(TARGETS QWhatToDo
  RUNTIME DESTINATION bin
  LIBRARY DESTINATION lib
  ARCHIVE DESTINATION lib
)

INCLUDE(InstallRequiredSystemLibraries)
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "qwhattodo")
SET(CPACK_PACKAGE_VENDOR "Tomasz Dubik")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/GPL.txt")
SET(CPACK_PACKAGE_VERSION_MAJOR ${APP_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${APP_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${APP_VERSION_PATCH})
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "QWhatToDo")
IF(WIN32 AND NOT UNIX)
SET(CPACK_NSIS_DISPLAY_NAME ${CPACK_PACKAGE_INSTALL_DIRECTORY} "QWhatToDo")
SET(CPACK_NSIS_CONTACT "tdubik@gmail.com")
ENDIF(WIN32 AND NOT UNIX)

INCLUDE(CPack)
